<?php 
$cookie_usuarioNB = $_COOKIE['proyecta_nb'];
$usuarioNB = explode('|', base64_decode($cookie_usuarioNB));

if($cookie_usuarioNB==''){
	header('Location: nube.php');
}
require_once('sipv2/includes/inc_funciones.php');

//$arr_nombres=usuarioNB[1];
// print_r($usuarioNB);
	
	$sqlAcole_py='';
	$sqlAcole_pers='';
	$sqlAcole_area='';
	
if($usuarioNB[3]=='PRO'){
	switch ($usuarioNB[5]) {
		case 'AdminTI':
		//echo "addd";
			$sqlAcole_py=" select 'proy' as  tp_carpeta ";
			$sqlAcole_pers=" select 'pers' as  tp_carpeta  ";
			$sqlAcole_area=" select 'a' as tp_carpeta ";
			break;
		case 'Gerencia':
			$sqlAcole_py=" select 'proy' as  tp_carpeta ";
			$sqlAcole_pers=" select distinct tp_carpeta FROM nube_carpt_pers where id_pers_acceso='{$usuarioNB[0]}'";
			$sqlAcole_area=" select 'a' as tp_carpeta ";
			break;
		case 'director':
			$sqlAcole_py=" select 'proy' as tp_carpeta ";
			$sqlAcole_pers=" select distinct tp_carpeta FROM nube_carpt_pers where id_pers_acceso='{$usuarioNB[0]}'";
			$sqlAcole_area=" select distinct tp_carpeta FROM nube_carpt_area where id_pers_acceso='{$usuarioNB[0]}'";
			break;
		default:
			 $sqlAcole_py="select distinct tp_carpeta FROM nube_carpt_proy where id_pers_acceso='{$usuarioNB[0]}'";
			 $sqlAcole_pers=" select distinct tp_carpeta FROM nube_carpt_pers where id_pers_acceso='{$usuarioNB[0]}'";
			 $sqlAcole_area=" select distinct tp_carpeta FROM nube_carpt_area where id_pers_acceso='{$usuarioNB[0]}'";
		 break;
	}

}else{
	// si es persona externa 
	$sqlAcole_py="select distinct tp_carpeta FROM nube_carpt_proy where id_pers_acceso='{$usuarioNB[0]}'";
	 $sqlAcole_pers=" select distinct tp_carpeta FROM nube_carpt_pers where id_pers_acceso='{$usuarioNB[0]}'";
	 $sqlAcole_area=" select distinct tp_carpeta FROM nube_carpt_area where id_pers_acceso='{$usuarioNB[0]}'";
}

     $sql="select  * from (
			{$sqlAcole_py}
		union
			{$sqlAcole_pers}
		union
			{$sqlAcole_area}
		
		)tabla ";
$result = fnp_ejecuta_query($sql,'S');


$varr_tp = array("proy" => "Proyecto", "pers" => "Personal", "a" => "Area");

?>
<!DOCTYPE html>
<html lang='es'>

<head>


	<meta charset='utf-8'>
	<link rel="stylesheet" type="text/css" href="sipv2/utilitarios/css/reset.css">
	<link rel="stylesheet" type="text/css" href="sipv2/utilitarios/css/login.css">
    <link rel="stylesheet" type="text/css" href="sipv2/utilitarios/css/general.css">

 
	<script type="text/javascript" src="sipv2/js/jquery-1.8.0.min.js"></script>
	<script type="text/javascript" src="sipv2/js/login_nube.js"></script>
    <script type="text/javascript" src="sipv2/js/general.js"></script>

   <style type="text/css">
   
   .centrar
	{
		position: absolute;
		/*nos posicionamos en el centro del navegador*/
		top:auto;
		/* top:5%; */
		left:50%;
		/*determinamos una anchura*/
		width:750px;
		/*indicamos que el margen izquierdo, es la mitad de la anchura*/
		margin-left:-375px;
		/*determinamos una altura*/
		height:90%;
		/*indicamos que el margen superior, es la mitad de la altura*/
		/* margin-top:-150px; */
		border:1px solid rgb(255,255,255); /* #808080;*/
		padding:5px;
		background:rgb(255,255,255);
	}
	
	ul.menu { /*list-style-image: url("imagenes/ok.png");*/	
		list-style: none;
		  margin: 0;
		  padding: 0;
		  width: 180px;
		  margin-left:3px;
   }
   
	ul.menu li a {
	color: #333;
	display: block;
	padding: 5px;
	text-decoration: none;
	font-size:11px;
	}
	 
	 li.document{
		background-image: url('sipv2/js/jquery.filetreeExterno/images/txt.png');
		background-repeat: no-repeat;
		background-position: 0px 0px;
		padding-left: 22px;
	}
		
	
	/* stilos para lisra archivos ---------------------  */
	UL.jqueryFileTree {
		font-family: Verdana, sans-serif;
		font-size: 11px;
		line-height: 18px;
		padding: 0px;
		margin: 0px;
	}
	
	UL.jqueryFileTree li {
		list-style: none;
		padding: 0px;
		padding-left: 10px;
		margin: 0px;
		white-space: nowrap;
		text-decoration: none !important;
	}
	
	ul.jqueryFileTree li span {
		display: inline-block;
		padding: 0 5px;
		margin: 0;
		color:rgb(153,153,153);
	}
	
	ul.jqueryFileTree li span.nom {
		width: 330px;
	}
	
	ul.jqueryFileTree li span.dat {
		width: 140px;
	}
	
	ul.jqueryFileTree li span.fec {
		width: 20px;
	}
	
	
	li.crpt_ad { 
		padding-top:3px!important; padding-left:30px !important; 
		background:url(sipv2/utilitarios/imagenes/file_ad.png) left center no-repeat; 
		border-bottom:1px solid rgb(204,204,204);  }
	
	li.crpt_ad:hover { 
		padding-top:3px!important; padding-left:30px !important; 
		background:url(sipv2/utilitarios/imagenes/file_ad.png) left center no-repeat;
		background-position: 0px 5px;
		background-color: #EBEFF1;  border-bottom:1px solid rgb(204,204,204);  }
	
	
    li.crpt_cnp { 
		padding-top:3px!important; padding-left:30px !important;
		background:url(sipv2/utilitarios/imagenes/file_comprt.png) left center no-repeat;
		border-bottom:1px solid rgb(204,204,204); }
	
	li.crpt_cnp:hover { 
		padding-top:3px!important; padding-left:30px !important;
		background:url(sipv2/utilitarios/imagenes/file_comprt.png) left center no-repeat;
		background-position: 0px 5px;
		background-color: #EBEFF1; border-bottom:1px solid rgb(204,204,204); }
		
	    li.list_cp { padding-top:3px!important; margin-top:5px !important; padding-left:30px !important;
		 background:url(sipv2/utilitarios/imagenes/file_comprt.png) left top no-repeat;
		  border-bottom:1px solid rgb(204,204,204);
		    }
	
	 a{text-decoration:none; color: rgb(102,102,102);}
	 a.patch:hover{ color: rgb(102,102,102) !important; text-decoration: underline;}
		
	listCP{ margin-top:5px;}
	
	#a_comp:hover{cursor:pointer;}
	
	.chat-bubble, .chat-bubble-bottom {
	border: 1px solid #E17AE6;
	}	
	
	#dv_cnlg{
		display: block;
		position: absolute;
		right: 2px;
		top: 26%;
		margin-top: 12px;
		min-width: 165px;
		max-width: 215px;
		z-index: 1;
		padding-bottom: 12px;
		border:1px solid #bdc4c9;
		border-radius: 5px;
		background:rgb(255,255,255);
		font-size:12px;
		
	}
		
	.chat-bubble-arrow {
		border-color: transparent transparent #fff transparent;
		border-style: solid;
		border-width: 9px;
		height: 0;
		width: 0;
		position: absolute;
		top: -17px;
		right: 30px;
	}
	.chat-bubble-arrow-border {
		border-color: transparent transparent #bdc4c9 transparent;
		border-style: solid;
		border-width: 9px;
		height: 0;
		width: 0;
		position: absolute;
		top: -19px;
		right: 30px;
	}
	
	.lg_itm{ padding:6px; padding-left:20px; padding-right:20px;}
	.bt_sl:hover{background:rgb(226,235,235);}
	
	.item_mail{ width: 80%;

overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;}

.item_espacio{ width: 80%;
	
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
}

	.cls_busc{border:1px solid rgb(204,204,204); border-radius: 5px; width:200px; float:right;}


   </style>
   
   <script type="text/javascript">
   	$(document).ready(function() {
       $('#lst_tp').change();
	   
	   
	  $('#dv_lista').on('click','.patch',function(){
		  	var v3=$(this).attr('data-tps');
			var v2=$(this).attr('data-py');
			var vl=$(this).attr('data-url');
			var v4=$(this).attr('data-ac');			
			var nom=$(this).text();
			var tp=$('#lst_tp').val();			

			relocate('nubemanagerfile.php',{'nurl':vl,'nom':nom,'vtp':tp,'tps':v3,'py':v2,'ac':v4});			
		
	  });
	  
	  $('#dv_lista').on('click','#a_comp',function(){
		  
		  if($(this).closest('li').find('.jqueryFileTree').is(':visible')){
		  $(this).closest('li').find('.jqueryFileTree').attr('style','display: none;');
		  }else{
			 $(this).closest('li').find('.jqueryFileTree').attr('style','');
		   }
	  		
	  });
	  
	  $('#dv_act_clg').on('click',function(){
	  		if($("#dv_cnlg").is(':visible')){
				$("#dv_cnlg").addClass('hidden');
			}else{
				$("#dv_cnlg").removeClass('hidden');
			}
	  });
	  
	  $('#txt_each').on('keyup',function(){
		  var cadn=$(this).val();
		  cadn=cadn.toLowerCase();
	  	
			// record list
			$('#lista_cp').find('.patch').each(function() {
                vlemt=$(this).closest('li');
				var sttxt=$(vlemt).find('.patch').text();
					sttxt=sttxt.toLowerCase();
				if( sttxt.indexOf(cadn) !=-1 ){
					// encuentra
					$(vlemt).removeClass('hidden');
				}else{
					// no encuentra
					$(vlemt).addClass('hidden');
				}
            });
			
	  });
	  
	  
    });
	
	
	 function relocate(page,params)
	 {
		  var body = document.body;
		  form=document.createElement('form'); 
		  form.method = 'POST'; 
		  form.action = page;
		  form.name = 'jsform';
		  for (index in params)
		  {
				var input = document.createElement('input');
				input.type='hidden';
				input.name=index;
				input.id=index;
				input.value=params[index];
				form.appendChild(input);
		  }	  		  			  
		  body.appendChild(form);
		form.submit();
	 }
	
	
   </script>
</head>
<body>

<div class="centrar" >
<div id="dv_cabesera" style="vertical-align:top; position:fixed;width:750px; background:rgb(255,255,255); margin-top:-6px;">
<br><br> 
    <div  style="margin-left:5px; vertical-align:top; " id="dv_cplg" >
    		<img src="sipv2/utilitarios/imagenes/logo.png" style="margin-left:120px;">  <!-- <span style="margin-left:30px; color:rgb(153,153,153); float:inherit; margin-top:-5px;">Proyecta</span> -->
    		<div style="float:right; font-size:12px; color:rgb(153,153,153); cursor:pointer;" id="dv_act_clg"><?php echo $usuarioNB[1];?> 
    			
    			<img src="sipv2/utilitarios/imagenes/desc.png" width="12"> 
    
			    <div id="dv_cnlg" class="hidden" style="ma">
			    	<br>
				    <div class="lg_itm" style="color:rgb(102,102,102);"><?php echo $usuarioNB[1];?></div>
			        <div class="lg_itm item_mail" title="<?php echo $usuarioNB[2];?>"><?php echo $usuarioNB[2];?></div>	
					<div class="lg_itm item_espacio" title="espacio"><?php echo "Espacio Utilizado ";?></div>			        		             
			        <div class="lg_itm bt_sl" style="color:#2895f1;">Salir</div>    	
			        <div class="chat-bubble-arrow-border"></div>
			        <div class="chat-bubble-arrow"></div>
			    </div>
   
    		</div>
    </div>
    <br>
    
    <div id=""> 
        <div class="cls_busc" id="" style="border:1px solid rgb(204,204,204); width:250px; float:right;">              
        <input type="text" style=" width:218px; float:right; border:none; color:rgb(153,153,153); font-size:11px;" placeholder="Buscar" id="txt_each" >
        <img src="sipv2/utilitarios/imagenes/imgSearch.png" style="float:left; margin-left:2px;" >
        </div>
     </div>
    <br><br><br>
       
    
    <div style=" float:right; width:620px; border:1px solid rgb(255,255,255); height:90%; font-size:12px;">
    	<div class="cabesera_lst">
              Tipo: <select name="lst_tp" id="lst_tp"> 
                <?php 
                    if(count($result)>0){
                        foreach($result as $nf){
                            echo "<option value='{$nf['tp_carpeta']}'> {$varr_tp[$nf['tp_carpeta']]} </option>";
                        }
                    }
                ?>
                </select>
            <br><br>
            <ul class="jqueryFileTree">
            <li class="head" style="border-bottom:1px solid rgb(204,204,204);">
            <span class="nom">Nombre</span><span class="dat">    </span><span class="fec">Ultima Modificación</span></li>
            </ul>
        </div>
        
    
    </div>    
        
</div>

<br>

<div style=" float:right; width:620px; border:1px solid rgb(255,255,255); height:90%; font-size:12px;">
<div class="cabesera_lst">
	<br><br><br><br><br><br><br><br><br><br><br> <br>  <br> <br>   
    <div id="dv_lista">
    </div>

    





    <br><br>        
</div>
</div>

</div>


</body>
</html>